﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using PostSharp.Laos;

namespace ConsolePostSharp
{
    [Serializable]
    [AttributeUsage(AttributeTargets.All, Inherited = true, AllowMultiple = false)]
    public class PermissionAttribute : OnMethodBoundaryAspect
    {
        public override void OnEntry(MethodExecutionEventArgs eventArgs)
        {
            if (!User.AddEnable)
            {
                Console.WriteLine("用户：【{0}】没有权限：【{1}】", User.UserID, eventArgs.Method);
                eventArgs.FlowBehavior = FlowBehavior.Return;
            }
        }
    }
}
